package ijij41.togetherTrain.common;


import ijij41.togetherTrain.*;
import ijij41.togetherTrain.R.*;
import android.app.Activity;
import android.content.*;
import android.os.Bundle;
import android.view.*;
import android.widget.*;

public class PersonActivity extends Activity implements Constants {

	private TextView tv_numberOfPerson;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.person);

		initComponent();

	}

	
	private void initComponent() {
		
		SeekBar sb = ((SeekBar) findViewById(R.id.seekBar));
		sb.setOnSeekBarChangeListener(listenGenerator);

		(findViewById(R.id.cfm_button)).setOnClickListener(mClickListener);
		(findViewById(R.id.btn_back_img)).setOnClickListener(mClickListener);
		tv_numberOfPerson = (TextView) findViewById(R.id.tv_numberOfPerson);

		Intent intent = getIntent();
		String person = intent.getStringExtra("PERSON");
		tv_numberOfPerson.setText(person);

		sb.incrementProgressBy(Integer.parseInt(person)-1);

	}
	
	

	Button.OnClickListener mClickListener = new Button.OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {

			case R.id.btn_back_img:
				finish();
				break;

			case R.id.cfm_button:
				setResult(PERSON_OK,
						(new Intent()).setAction((String) tv_numberOfPerson
								.getText()));

				finish();
				break;

			default:
				break;
			}

		}
	};

	private SeekBar.OnSeekBarChangeListener listenGenerator = new SeekBar.OnSeekBarChangeListener() {
		@Override
		// thumb 을 놓았을때 날라오는 메세지
		public void onStopTrackingTouch(SeekBar seekBar) {

			// m_textTracking.setText(new
			// StringBuilder().append("Tracking Stop"));
		}

		@Override
		// thumb 을 잡았을때 날라오는 메세지
		public void onStartTrackingTouch(SeekBar seekBar) {

			// m_textTracking
			// .setText(new StringBuilder().append("Tracking Start"));

		}

		@Override
		// thumb 의 위치가 변경될 때마다 오는 메세지
		public void onProgressChanged(SeekBar seekBar, int progress,
				boolean fromUser) {


			tv_numberOfPerson.setText(new StringBuilder().append(progress + 1));
		}
	};

}